

function loadXMLDoc()
{
var xmlhttp;
var txt,x,i,vc, wd, bd, ad, sc, rc, ng, sv, rv, pc;
var serverAddress="/EasyWayServer/info";
var shown=0;

if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    xmlDoc=xmlhttp.responseXML;
    x=xmlDoc.getElementsByTagName("vehiclesCount");
    vc=x[0].childNodes[0].nodeValue + "<br />";
    document.getElementById("vc").innerHTML=vc;


    


    x=xmlDoc.getElementsByTagName("properlyConfigured");
    pc=x[0].childNodes[0].nodeValue;
    document.getElementById("pc").innerHTML="<img src=\"/EasyWayServer/static/img/greenLight.png\">";



    x=xmlDoc.getElementsByTagName("system");
    vc=x[0].childNodes[0].nodeValue + "<br />";
    document.getElementById("system").innerHTML="<b>"+vc+"</b>";

    x=xmlDoc.getElementsByTagName("cpuUsage");
    pc=x[0].childNodes[0].nodeValue;
   
    var pb=document.getElementById('progressbar1');
    if (val <20){
	    pb.setAttribute("class","ui-progressbar-end");
    }
    var val = parseInt(pc*100);
$("#progressbar1").progressbarVertical({

        value: val,
        width: 23,
        height: 460,
	

    });

$("#progressbar1").progressbarVertical()
        .removeClass("begin middle end")
        .addClass(val < 51 ? "begin" : val < 72 ? "middle" : "end");
	









    x=xmlDoc.getElementsByTagName("nonGeneratedSegments");
    ng=x[0].childNodes[0].nodeValue;
    document.getElementById("ng").innerHTML=ng;


    x=xmlDoc.getElementsByTagName("stopsCount");
    sc=x[0].childNodes[0].nodeValue;
    document.getElementById("sc").innerHTML=sc;


    x=xmlDoc.getElementsByTagName("routesCount");
    rc=x[0].childNodes[0].nodeValue;;
    document.getElementById("rc").innerHTML=rc;

    x=xmlDoc.getElementsByTagName("routesVersion");
    rv=x[0].childNodes[0].nodeValue;
    document.getElementById("rv").innerHTML=rv;

    x=xmlDoc.getElementsByTagName("stopsVersion");
    sv=x[0].childNodes[0].nodeValue;
    document.getElementById("sv").innerHTML=sv;
	 
    if ((sc==0 || sv==0 || rv==0 || rc==0 || ng>0)&& isShown(1)==0){
	if(sc==0 || sv==0){
		var nS=document.getElementById('noStops');
		nS.innerHTML="Plik przystanków pusty! Dodaj przystanki!";
		}	
	if(rc==0 || rv==0){
		var nR=document.getElementById('noRoutes');
		nR.innerHTML="Plik tras pusty! Dodaj trasy!";
		}

	if(ng>0){
		var nR=document.getElementById('notGenerated');
		nR.innerHTML="Istnieją trasy ("+ng+") z niewygenerowanymi statystykami! <br>Przejdź do zakładki Statystyki i wygeneruj brakujące segmenty tras lub wczytaj plik ze statystykami!";
	}
	hideAllMessages();	
	setShown(1,1);			  
	$('.'+'warning').animate({bottom:"0"}, 500);


	}

    x=xmlDoc.getElementsByTagName("waitingDevicesCount");
    wd=x[0].childNodes[0].nodeValue;
    document.getElementById("wd").innerHTML=wd;
	if (wd>0 && isShown(0)==0){

	var cnt=document.getElementById('wdCount');
	cnt.innerHTML="( "+wd+" )";
  	hideAllMessages();	
	setShown(0,1);			  
	$('.'+'info').animate({bottom:"0"}, 500);
	}

    x=xmlDoc.getElementsByTagName("authorizedDevicesCount");
    ad=x[0].childNodes[0].nodeValue;
    document.getElementById("ad").innerHTML=ad;

    x=xmlDoc.getElementsByTagName("blockedDevicesCount");
    bd=x[0].childNodes[0].nodeValue;
    document.getElementById("bd").innerHTML=bd;

x=xmlDoc.getElementsByTagName("perSecond");
    bd=x[0].childNodes[0].nodeValue;
    document.getElementById("perSecond").innerHTML=bd;

x=xmlDoc.getElementsByTagName("totalQueries");
    bd=x[0].childNodes[0].nodeValue;
    document.getElementById("totalQueries").innerHTML=bd;

x=xmlDoc.getElementsByTagName("perSecondDevices");
    bd=x[0].childNodes[0].nodeValue;
    document.getElementById("perSecondDevices").innerHTML=bd;

x=xmlDoc.getElementsByTagName("totalQueriesDevices");
    bd=x[0].childNodes[0].nodeValue;
    document.getElementById("totalQueriesDevices").innerHTML=bd;






   



    }
  }
xmlhttp.open("GET",serverAddress,true);
xmlhttp.send();
//alert('ok');
}
